﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//test commit Kermit
namespace Black_Jack_Basic_Strategy
{
    class RandomizedKeySet
    {
        int[] myRandomSetArray;
        Random randomHand = new Random();

        public static void PrintValues(int[] myArr)
        {
       
            foreach (int i in myArr)
            {
                Console.Write("\t{0}", i);
            }
            Console.WriteLine();
            Console.ReadKey();

        }

        //public static void ShuffleSet(int count)
        public int[] ShuffleSet(int iCount)
        { 
            //
            int iMin = 1;
            int iRandom;
            int iLoadCount = iCount;
            int arrayCount = 0;

            int[] countArray = new int[iCount];
            int[] newArray = new int[iCount];

            //Load array
            int iLoadKeys = 0;
            for (var i = 0; i < iCount; i++)
            {
                iLoadKeys++;
                countArray[i] = iLoadKeys;
            }
            
            while (iLoadCount != 0)
            {
                iRandom = RandomNumber(iMin, iCount + 1);
                if (countArray[iRandom - 1] != 0)
                {
                    newArray[arrayCount] = iRandom;
                    countArray[iRandom - 1] = 0;
                    arrayCount++;
                    iLoadCount--;
                }
            }

            return newArray;
        }

        private int RandomNumber( int min, int max)
        {
            return randomHand.Next(min, max);
        }


    }
}
